package as3.carcassone.model {
	import as3.carcassone.GameConstants;
	public class PlayerManager {

		private static var _instance : PlayerManager;
		
		private var _players : Vector.<Player> = new Vector.<Player>();
		public var totalplayers : int = 0;
		
		public static function get instance() : PlayerManager {
			if( _instance == null ) _instance = new PlayerManager( new SingletonEnforcer() );
			return _instance;
		}

		
		public function PlayerManager( enforcer : SingletonEnforcer ) {
			if( !enforcer ) trace( "ERROR: PlayerManager should not be instantiated with 'new'. Use it like: PlayerManager.instance.etcetera" );
		}



		public function addPlayers( num : int ) : void
		{
			totalplayers = num;
			
			var p : Player;
			for (var i : int = 0; i < totalplayers; i++) {
				p = new Player();
				p.color = GameConstants.COLORS[i];
				_players.push( p );
			}
		}



		public function get players() : Vector.<Player>
		{
			return _players;
		}
	}
}
class SingletonEnforcer {}